package e.odbo.data.model;

import e.odbo.data.util.StringUtils;



public class TableForeignKey {
    String table;
    String[] columns;
    String refTable;
    String[] refColumns;
    ForeignKeyFlag cascadeFlag_del ;
    ForeignKeyFlag cascadeFlag_update ;


    public TableForeignKey(String table, String[] columns, String refTable, String[] refColumns) {
        this(table,  columns, refTable,  refColumns,ForeignKeyFlag.NO_SET);
    }

    public TableForeignKey(String table, String[] columns, String refTable, String[] refColumns, ForeignKeyFlag cascadeFlag_del) {
        this(table,  columns, refTable,  refColumns,cascadeFlag_del,ForeignKeyFlag.NO_SET);
    }

    public TableForeignKey(String table, String[] columns, String refTable, String[] refColumns, ForeignKeyFlag cascadeFlag_del, ForeignKeyFlag cascadeFlag_update) {
        this.table = table;
        this.columns = columns;
        this.refTable = refTable;
        this.refColumns = refColumns;
        this.cascadeFlag_del = cascadeFlag_del;
        this.cascadeFlag_update=cascadeFlag_update;
    }

    public String getTable() {
        return table;
    }

    public void setTable(String table) {
        this.table = table;
    }

    public String[] getColumns() {
        return columns;
    }

    public void setColumns(String[] columns) {
        this.columns = columns;
    }

    public String getRefTable() {
        return refTable;
    }

    public void setRefTable(String refTable) {
        this.refTable = refTable;
    }

    public String[] getRefColumns() {
        return refColumns;
    }

    public void setRefColumns(String[] refColumns) {
        this.refColumns = refColumns;
    }

    public boolean isCascadeFlag_del() {
        return cascadeFlag_del!=ForeignKeyFlag.NO_SET;
    }

    public void setCascadeFlag_del(boolean cascadeFlag_del) {
        this.cascadeFlag_del = ForeignKeyFlag.CASCADE;
    }

    public String getName(){
        String ret=table+ StringUtils.join(columns,'_')+refTable+StringUtils.join(refColumns,'_');
        return ret;
    }

    public boolean isCascadeFlag_update() {
        return cascadeFlag_update!=ForeignKeyFlag.NO_SET;
    }

    public ForeignKeyFlag getCascadeFlag_del() {
        return cascadeFlag_del;
    }

    public ForeignKeyFlag getCascadeFlag_update() {
        return cascadeFlag_update;
    }
}
